package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldCheckCycle;
import com.cleaningcloud.cld.service.ICldCheckCycleService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 考核周期Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/checkCycle")
public class CldCheckCycleController extends BaseController
{
    @Autowired
    private ICldCheckCycleService cldCheckCycleService;

    /**
     * 查询考核周期列表
     */
    @RequiresPermissions("cld:checkCycle:list")
    @GetMapping("/list")
    public TableDataInfo list(CldCheckCycle cldCheckCycle)
    {
        startPage();
        List<CldCheckCycle> list = cldCheckCycleService.selectCldCheckCycleList(cldCheckCycle);
        return getDataTable(list);
    }

    /**
     * 导出考核周期列表
     */
    @RequiresPermissions("cld:checkCycle:export")
    @Log(title = "考核周期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldCheckCycle cldCheckCycle)
    {
        List<CldCheckCycle> list = cldCheckCycleService.selectCldCheckCycleList(cldCheckCycle);
        ExcelUtil<CldCheckCycle> util = new ExcelUtil<CldCheckCycle>(CldCheckCycle.class);
        util.exportExcel(response, list, "考核周期数据");
    }

    /**
     * 获取考核周期详细信息
     */
    @RequiresPermissions("cld:checkCycle:query")
    @GetMapping(value = "/{cycleId}")
    public AjaxResult getInfo(@PathVariable("cycleId") Long cycleId)
    {
        return success(cldCheckCycleService.selectCldCheckCycleByCycleId(cycleId));
    }

    /**
     * 新增考核周期
     */
    @RequiresPermissions("cld:checkCycle:add")
    @Log(title = "考核周期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldCheckCycle cldCheckCycle)
    {
        return toAjax(cldCheckCycleService.insertCldCheckCycle(cldCheckCycle));
    }

    /**
     * 修改考核周期
     */
    @RequiresPermissions("cld:checkCycle:edit")
    @Log(title = "考核周期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldCheckCycle cldCheckCycle)
    {
        return toAjax(cldCheckCycleService.updateCldCheckCycle(cldCheckCycle));
    }

    /**
     * 删除考核周期
     */
    @RequiresPermissions("cld:checkCycle:remove")
    @Log(title = "考核周期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cycleIds}")
    public AjaxResult remove(@PathVariable Long[] cycleIds)
    {
        return toAjax(cldCheckCycleService.deleteCldCheckCycleByCycleIds(cycleIds));
    }


    /**
     * 查询考核周期列表
     */
    @GetMapping("/getList")
    public AjaxResult getList(CldCheckCycle cldCheckCycle)
    {
        List<CldCheckCycle> list = cldCheckCycleService.selectCldCheckCycleList(cldCheckCycle);
        return success(list);
    }
}
